/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.fleroy.gedapp.task;

import java.io.File;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.jdesktop.application.Task;

/**
 *
 * @author fleroy
 */
public class OpenFileTask extends Task<Void, Void>{

    /**
     * Logger
     */
    private final static Logger LOGGER = Logger.getLogger(OpenFileTask.class);

    private File moCurrentFile = null;

    public OpenFileTask(org.jdesktop.application.Application app, File poCurrentFile) {
            super(app);
            moCurrentFile = poCurrentFile;
    }

    @Override
    protected Void doInBackground() {
        try {
            setMessage("Chargement du fichier...");
            Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + moCurrentFile.getAbsolutePath());
        } catch (IOException ex) {
            LOGGER.error(ex.getMessage(), ex);
        }
        return null;
    }

    protected void succeeded() {
    }
}
